package my.study.com.mysql.jdbc.examples.example1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Ex4 {

	/**
	 * @param args
	 * @throws ClassNotFoundException
	 * @throws IllegalAccessException
	 * @throws InstantiationException
	 * @throws SQLException
	 */
	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException, ClassNotFoundException, SQLException {

		String url = "jdbc:mysql://tc-dba-crm-test00.tc.baidu.com:8806/crm_db";
		String user = "crm";
		String password = "123456";

		Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection conn = DriverManager.getConnection(url, user, password);
		conn.setAutoCommit(true);
		PreparedStatement ps = conn
				.prepareStatement("select custid, account, consumeavg, paytotal, paytimes, latestpaytime, latestpaymoney, latestpayway " +
						"from custfund where custid = 880");
		long start = System.currentTimeMillis();
		
		ResultSet rs = ps.executeQuery();
		while (rs.next()) {
			System.out.println(rs.getObject(1));
			System.out.println(rs.getObject(2));
			System.out.println(rs.getObject(6));
			System.out.println(rs.getObject(8));
		}
		System.out.println();
		System.out.println(System.currentTimeMillis() - start);
		conn.close();

	}

}
